library (foreign)
setwd('C:/Users/Sara/Desktop/Sara/Documents/MIT/Work for Adam/Draft Lottery/')

anesdata<-read.dta(file="ANES Data Files/final2.dta")

library (Matching)
attach(anesdata)

# Bootstrapped K-S Tests
# Fourth Quarter/Full Sample - Table 1

# Education - 4 Category
ks.boot(VCF0110[q4==1&VCF0110>0], VCF0110[q4==0&VCF0110>0], nboots=1000, alternative = c("two.sided"), print.level=0)
# Education - 7 Categroy
ks.boot(VCF0140a[q4==1&VCF0140a>0&VCF0140a<8], VCF0140a[q4==0&VCF0140a>0&VCF0140a<8], nboots=1000, alternative = c("two.sided"), print.level=0)
# Income
ks.boot(VCF0114[q4==1&VCF0114>0], VCF0114[q4==0&VCF0114>0], nboots=1000, alternative = c("two.sided"), print.level=0)
# Political Knowledge (Pre)
ks.boot(VCF0050a[q4==1&VCF0050a<6], VCF0050a[q4==0&VCF0050a<6], nboots=1000, alternative = c("two.sided"), print.level=0)
# Political Knowledge (Post)
ks.boot(VCF0050b[q4==1&VCF0050b>0&VCF0050b<6], VCF0050b[q4==0&VCF0050b>0&VCF0050b<6], nboots=1000, alternative = c("two.sided"), print.level=0)
# Interest in Campaigns
ks.boot(VCF0310[q4==1&VCF0310 >0&VCF0310 <8], VCF0310[q4==0&VCF0310 >0&VCF0310 <8], nboots=1000, alternative = c("two.sided"), print.level=0)
# Party Identification
ks.boot(VCF0301[q4==1&VCF0301>0&VCF0301<9], VCF0301[q4==0&VCF0301>0&VCF0301<9], nboots=1000, alternative = c("two.sided"), print.level=0)
# Lib/Con Ideology
ks.boot(VCF0803[q4==1&VCF0803>0&VCF0803<9], VCF0803[q4==0&VCF0803>0&VCF0803<9], nboots=1000, alternative = c("two.sided"), print.level=0)
# Voter Registration
ks.boot(VCF0737[q4==1&VCF0737>0&VCF0737<9], VCF0737[q4==0&VCF0737>0&VCF0737<9], nboots=1000, alternative = c("two.sided"), print.level=0)
# Voter Participation
ks.boot(VCF0702[q4==1&VCF0702>0&VCF0702<9], VCF0702[q4==0&VCF0702>0&VCF0702<9], nboots=1000, alternative = c("two.sided"), print.level=0)


# Bootstrapped K-S Tests
# Fourth Quarter/Draft Cohort - Table 2

# Education - 4 Category
ks.boot(VCF0110[q4==1&VCF0110>0& nam==1], VCF0110[q4==0&VCF0110>0& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)
# Education - 7 Categroy
ks.boot(VCF0140a[q4==1&VCF0140a>0&VCF0140a<8& nam==1], VCF0140a[q4==0&VCF0140a>0&VCF0140a<8& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)
# Income
ks.boot(VCF0114[q4==1&VCF0114>0& nam==1], VCF0114[q4==0&VCF0114>0& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)
# Political Knowledge (Pre)
ks.boot(VCF0050a[q4==1&VCF0050a<6& nam==1], VCF0050a[q4==0&VCF0050a<6& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)
# Political Knowledge (Post)
ks.boot(VCF0050b[q4==1&VCF0050b>0&VCF0050b<6& nam==1], VCF0050b[q4==0&VCF0050b>0&VCF0050b<6& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)
# Interest in Campaigns
ks.boot(VCF0310[q4==1&VCF0310 >0&VCF0310 <8& nam==1], VCF0310[q4==0&VCF0310 >0&VCF0310 <8& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)
# Party Identification
ks.boot(VCF0301[q4==1&VCF0301>0&VCF0301<9& nam==1], VCF0301[q4==0&VCF0301>0&VCF0301<9& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)
# Lib/Con Ideology
ks.boot(VCF0803[q4==1&VCF0803>0&VCF0803<9& nam==1], VCF0803[q4==0&VCF0803>0&VCF0803<9& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)
# Voter Registration
ks.boot(VCF0737[q4==1&VCF0737>0&VCF0737<9& nam==1], VCF0737[q4==0&VCF0737>0&VCF0737<9& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)
# Voter Participation
ks.boot(VCF0702[q4==1&VCF0702>0&VCF0702<9& nam==1], VCF0702[q4==0&VCF0702>0&VCF0702<9& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)

# Bootstrapped K-S Tests
# First Quarter/Full Sample - Online Appendix Table 1

# Education - 4 Category
ks.boot(VCF0110[q1==1&VCF0110>0], VCF0110[q1==0&VCF0110>0], nboots=1000, alternative = c("two.sided"), print.level=0)
# Education - 7 Categroy
ks.boot(VCF0140a[q1==1&VCF0140a>0&VCF0140a<8], VCF0140a[q1==0&VCF0140a>0&VCF0140a<8], nboots=1000, alternative = c("two.sided"), print.level=0)
# Income
ks.boot(VCF0114[q1==1&VCF0114>0], VCF0114[q1==0&VCF0114>0], nboots=1000, alternative = c("two.sided"), print.level=0)
# Political Knowledge (Pre)
ks.boot(VCF0050a[q1==1&VCF0050a<6], VCF0050a[q1==0&VCF0050a<6], nboots=1000, alternative = c("two.sided"), print.level=0)
# Political Knowledge (Post)
ks.boot(VCF0050b[q1==1&VCF0050b>0&VCF0050b<6], VCF0050b[q1==0&VCF0050b>0&VCF0050b<6], nboots=1000, alternative = c("two.sided"), print.level=0)
# Interest in Campaigns
ks.boot(VCF0310[q1==1&VCF0310 >0&VCF0310 <8], VCF0310[q1==0&VCF0310 >0&VCF0310 <8], nboots=1000, alternative = c("two.sided"), print.level=0)
# Party Identification
ks.boot(VCF0301[q1==1&VCF0301>0&VCF0301<9], VCF0301[q1==0&VCF0301>0&VCF0301<9], nboots=1000, alternative = c("two.sided"), print.level=0)
# Lib/Con Ideology
ks.boot(VCF0803[q1==1&VCF0803>0&VCF0803<9], VCF0803[q1==0&VCF0803>0&VCF0803<9], nboots=1000, alternative = c("two.sided"), print.level=0)
# Voter Registration
ks.boot(VCF0737[q1==1&VCF0737>0&VCF0737<9], VCF0737[q1==0&VCF0737>0&VCF0737<9], nboots=1000, alternative = c("two.sided"), print.level=0)
# Voter Participation
ks.boot(VCF0702[q1==1&VCF0702>0&VCF0702<9], VCF0702[q1==0&VCF0702>0&VCF0702<9], nboots=1000, alternative = c("two.sided"), print.level=0)

# Bootstrapped K-S Tests
# First Quarter/Draft Cohort - Online Appendix Table 2

# Education - 4 Category
ks.boot(VCF0110[q1==1&VCF0110>0& nam==1], VCF0110[q1==0&VCF0110>0& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)
# Education - 7 Categroy
ks.boot(VCF0140a[q1==1&VCF0140a>0&VCF0140a<8& nam==1], VCF0140a[q1==0&VCF0140a>0&VCF0140a<8& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)
# Income
ks.boot(VCF0114[q1==1&VCF0114>0& nam==1], VCF0114[q1==0&VCF0114>0& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)
# Political Knowledge (Pre)
ks.boot(VCF0050a[q1==1&VCF0050a<6& nam==1], VCF0050a[q1==0&VCF0050a<6& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)
# Political Knowledge (Post)
ks.boot(VCF0050b[q1==1&VCF0050b>0&VCF0050b<6& nam==1], VCF0050b[q1==0&VCF0050b>0&VCF0050b<6& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)
# Interest in Campaigns
ks.boot(VCF0310[q1==1&VCF0310 >0&VCF0310 <8& nam==1], VCF0310[q1==0&VCF0310 >0&VCF0310 <8& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)
# Party Identification
ks.boot(VCF0301[q1==1&VCF0301>0&VCF0301<9& nam==1], VCF0301[q1==0&VCF0301>0&VCF0301<9& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)
# Lib/Con Ideology
ks.boot(VCF0803[q1==1&VCF0803>0&VCF0803<9& nam==1], VCF0803[q1==0&VCF0803>0&VCF0803<9& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)
# Voter Registration
ks.boot(VCF0737[q1==1&VCF0737>0&VCF0737<9& nam==1], VCF0737[q1==0&VCF0737>0&VCF0737<9& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)
# Voter Participation
ks.boot(VCF0702[q1==1&VCF0702>0&VCF0702<9& nam==1], VCF0702[q1==0&VCF0702>0&VCF0702<9& nam==1], nboots=1000, alternative = c("two.sided"), print.level=0)